/*************************************************************************
* filename: pushrod_bsp.h
* Abstract: The interface of pushrod
* describe: The interface of pushrod
* author:   zhw
* version: 	v1.1
* date: 	2020-05-17
*************************************************************************/
#ifndef _BSP_PUSHROD_H_
#define _BSP_PUSHROD_H_

#include "pushrod_cfg.h"

#define PUSH_DEV_HEAD				PUSHROD_DEV1
#define PUSH_DEV_SEAT				PUSHROD_DEV2
#define PUSH_DEV_FOOT				PUSHROD_DEV3


// all pushrod dev id
#define PUSHROD_NONE    (pushrod_u16_t)0x0000
#define PUSHROD_DEV1    (pushrod_u16_t)0x0001
#define PUSHROD_DEV2    (pushrod_u16_t)0x0002
#define PUSHROD_DEV3    (pushrod_u16_t)0x0004
#define PUSHROD_DEV4    (pushrod_u16_t)0x0008
#define PUSHROD_DEV5    (pushrod_u16_t)0x0010
#define PUSHROD_DEV6    (pushrod_u16_t)0x0020
#define PUSHROD_DEVALL  (pushrod_u16_t)0xFFFF

typedef enum {
    PUSHROD_STOP = 0x00,
    PUSHROD_OPEN,
    PUSHROD_CLOSE
} pushrod_sta_t;

#if PUSHROD_MEM
typedef struct {
    pushrod_s32_t current_position[PUSHROD_NUM];        /*<!推杆当前的位置*/
    pushrod_sta_t status[PUSHROD_NUM];                  /*<!推杆的工作状态*/
} pushrod_info_t;
#endif

/**
 * @brief:  推杆初始化,使用驱动必须调用
 */
void Pushrod_Init(void);

/**
 * @brief: 推杆处理主程序, 需放入主循环中调用
 */
void Pushrod_Process(void);

/**
 * @brief: 推杆操作函数
 *
 * @param: dev:设备号 `PUSHROD_DEV1 - PUSHROD_DEV6`
 * @param: sta:设置状态 `pushrod_sta_t`
 */
void Pushrod_Opt(pushrod_u16_t dev, pushrod_sta_t sta);


#if PUSHROD_MEM
/**
 * @brief: 推杆坐标捕获
 *
 * @param: dev:设备号 `PUSHROD_DEV1 - PUSHROD_DEV6`
 * @param: value:定时器捕获电平脉冲时间
 */
void Pushrod_Capture(pushrod_u16_t dev, pushrod_u16_t value);

/**
 * @brief: 设置记忆位置
 *
 * @param: point:设置推杆记忆位置值
 */
void Pushrod_Set_Point(pushrod_s32_t *point);

/**
 * @brief: 返回记忆位置
 *
 * @param: point:返回推杆的记忆位置
 */
void Pushrod_Back_Point(pushrod_s32_t *point);

/**
 * @brief: 设置推杆状态信息
 *
 * @param: Info: 详见`pushrod_info_t`
 */
void Pushrod_Set_Info(pushrod_info_t *Info);

/**
 * @brief: 获取状态信息
 *
 * @param: Info: 详见`pushrod_info_t`
 */
void Pushrod_Get_Info(pushrod_info_t *info);
#endif

#endif /* ifndef _BSP_PUSHROD_H_ */

